package com.ruoyi.cbs.contract.service.impl;

import java.util.List;

import com.ruoyi.cbs.contract.domain.ContractorInsurance;
import com.ruoyi.cbs.contract.mapper.ContractorInsuranceMapper;
import com.ruoyi.cbs.contract.service.IContractorInsuranceService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 承包商保险Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-10-31
 */
@Service
public class ContractorInsuranceServiceImpl implements IContractorInsuranceService
{
    @Autowired
    private ContractorInsuranceMapper contractorInsuranceMapper;

    /**
     * 查询承包商保险
     * 
     * @param id 承包商保险主键
     * @return 承包商保险
     */
    @Override
    public ContractorInsurance selectContractorInsuranceById(Long id)
    {
        return contractorInsuranceMapper.selectContractorInsuranceById(id);
    }

    /**
     * 查询承包商保险列表
     * 
     * @param contractorInsurance 承包商保险
     * @return 承包商保险
     */
    @Override
    public List<ContractorInsurance> selectContractorInsuranceList(ContractorInsurance contractorInsurance)
    {
        return contractorInsuranceMapper.selectContractorInsuranceList(contractorInsurance);
    }

    /**
     * 新增承包商保险
     * 
     * @param contractorInsurance 承包商保险
     * @return 结果
     */
    @Override
    public int insertContractorInsurance(ContractorInsurance contractorInsurance)
    {
        contractorInsurance.setCreateTime(DateUtils.getNowDate());
        contractorInsurance.setId(IdFactory.newLongId());
        if (contractorInsurance.getCreateBy() == null) {
            contractorInsurance.setCreateBy("admin");
        }
        return contractorInsuranceMapper.insertContractorInsurance(contractorInsurance);
    }

    /**
     * 修改承包商保险
     * 
     * @param contractorInsurance 承包商保险
     * @return 结果
     */
    @Override
    public int updateContractorInsurance(ContractorInsurance contractorInsurance)
    {
        contractorInsurance.setUpdateTime(DateUtils.getNowDate());
        return contractorInsuranceMapper.updateContractorInsurance(contractorInsurance);
    }

    /**
     * 批量删除承包商保险
     * 
     * @param ids 需要删除的承包商保险主键
     * @return 结果
     */
    @Override
    public int deleteContractorInsuranceByIds(Long[] ids)
    {
        return contractorInsuranceMapper.deleteContractorInsuranceByIds(ids);
    }

    /**
     * 删除承包商保险信息
     * 
     * @param id 承包商保险主键
     * @return 结果
     */
    @Override
    public int deleteContractorInsuranceById(Long id)
    {
        return contractorInsuranceMapper.deleteContractorInsuranceById(id);
    }
}
